package com.frain.springcloud.listener.sublistener;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import com.frain.springcloud.listener.entity.MyEvent;
import com.frain.springcloud.listener.entity.MyTwoEvent;

@Component
public class MyListenerTwo implements ApplicationListener<MyEvent> {

    @Override
    public void onApplicationEvent(MyEvent event) {

        if (event instanceof MyTwoEvent) {
            MyTwoEvent twoEvent = (MyTwoEvent) event;
            System.out.println(twoEvent.getSource());
            System.out.println(twoEvent.getUserName());
            System.out.println(twoEvent.getPassword());
            twoEvent.sayTwo();

        }

    }

}
